import { BuffEffect } from "../../../shared/interface";

export enum BuffLisent {
    数值引用,
    函数调用
}
export default class buff_item {
    from_id:string = 'none';
    endTime: number = 0;
    key: BuffEffect = BuffEffect.none;
    val: number = 0;
    from: any;
    constructor(
        endTime: number,
        key: BuffEffect,
        val: number,
        from: any
    ) {
        this.from_id = from.sk_id;
        this.endTime = endTime;
        this.key = key;
        this.val = val;
        this.from = from;
    }
    /**
     * 查询剩余秒数
     */
    surplusTime_s(){
        return Number(((this.endTime - Date.now()) / 1000).toFixed(1))
    }
    /**
     * 相同buff  覆盖
     */
    cover(bf:buff_item){
        let ref = true;
        if(bf.val == this.val){
            ref = false;
        }
        // 比较时间大小
        this.endTime = bf.endTime;
        this.val = bf.val;
        this.from = bf.from;
        return ref;
    }

}